package alu {
	import actors.PxActor;
	
	import interfaces.PxIAlu;
	
	public class ExecuteCommand implements PxIAlu {
		private var _actor:PxActor;
		private var _command:String
		
		private var _destroyed:Boolean;
		
		public function ExecuteCommand(actorIn:PxActor, commandIn:String) {
			_actor = actorIn;
			_command = commandIn;
			_destroyed = false;
		}
		
		public function update():void {
			_actor[_command]();
			_actor.aluIndex ++;
		}
		
		public function clone():PxIAlu {
			return new ExecuteCommand(_actor, _command);
		}
		
		public function set actor(actorIn:PxActor):void {
			_actor = actorIn;
		}
		
		public function get destroyed():Boolean {
			return _destroyed;
		}
		
		public function destroy():void {
			if (destroyed)
				return;
			_destroyed = true;
			
			_actor.destroy();
			_actor = null;
		}
	}
}
